package org.teachertools.web.forms;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.teachertools.web.struts.BaseActionForm;

public class ReportForm extends BaseActionForm
{
    private static final long serialVersionUID = -7282200242051947496L;

    private Long idLivret = null;
    private Long idClasse = null;
	private Long[] eleveIds = null;
	private String exportPath = null;
	private String reportName = null;

	/**
	 * 
	 */
	public ReportForm()
	{
		super();
	}
	/**
	 * @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
	 */
    @Override
    public void reset() {
		idLivret = null;
		idClasse = null;
		eleveIds = null;
		exportPath = null;
		reportName = null;
    }
	/**
	 * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
	 */
	@Override
	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
	{
		ActionErrors errors = new ActionErrors();
		if (mapping.getPath().startsWith("/init"))
			return errors;
		if (eleveIds == null || eleveIds.length == 0)			
			errors.add("libelle", new ActionMessage("error.required", getMessage(request, "field.eleve"))); 
		if (StringUtils.isEmpty(exportPath))
			errors.add("libelle", new ActionMessage("error.required", getMessage(request, "field.exportPath"))); 
		return errors;
	}
	/**
     * @return the nomLivret
     */
    public Long getIdLivret()
    {
    	return idLivret;
    }
	/**
     * @param pNomLivret the nomLivret to set
     */
    public void setIdLivret(Long pIdLivret)
    {
    	idLivret = pIdLivret;
    }
	/**
	 * @return Returns the idClasse.
	 */
	public Long getIdClasse()
	{
		return this.idClasse;
	}
	/**
	 * @param pIdClasse The idClasse to set.
	 */
	public void setIdClasse(Long pIdClasse)
	{
		this.idClasse = pIdClasse;
	}
	/**
	 * @return Returns the eleveIds.
	 */
	public Long[] getEleveIds()
	{
		return this.eleveIds;
	}
	/**
	 * @param pEleveIds The eleveIds to set.
	 */
	public void setEleveIds(Long[] pEleveIds)
	{
		this.eleveIds = pEleveIds;
	}
	/**
	 * @return Returns the exportPath.
	 */
	public String getExportPath()
	{
		return this.exportPath;
	}
	/**
	 * @param pExportPath The exportPath to set.
	 */
	public void setExportPath(String pExportPath)
	{
		this.exportPath = pExportPath;
	}
	/**
     * @return the reportName
     */
    public String getReportName()
    {
    	return reportName;
    }
	/**
     * @param pReportName the reportName to set
     */
    public void setReportName(String pReportName)
    {
    	reportName = pReportName;
    }
}
